package com.itheima.server.controller;

import com.itheima.model.vo.PeachblossomVo;
import com.itheima.server.service.PeachblossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RequestMapping("/peachblossom")
@RestController
public class PeachblossomController {
    @Autowired
    private PeachblossomService peachblossomService;

    /*桃花传音-发送语音*/
    @PostMapping
    public ResponseEntity upload(MultipartFile soundFile) throws IOException {
        peachblossomService.upload(soundFile);
        return ResponseEntity.ok(null);
    }

    /*桃花传音-接收语音*/
    @GetMapping
    public ResponseEntity findOne() {
        PeachblossomVo vo = peachblossomService.findOne();
        return ResponseEntity.ok(vo);
    }
}
